// -----------------------------------------------
// Author:     code34 nicolas_boiteux@yahoo.fr
// Edited by:  Neumatic
// Warcontext: Bring unit to a position
// -----------------------------------------------

private ["_unit","_targetpos","_missioncomplete"];

_unit      = _this select 0;
_targetpos = _this select 1;

_missioncomplete = false;

while {!_missioncomplete} do {
	sleep 1;
	if ((!alive _unit) or (damage _unit > 0.9)) then {
		wcmessageW = [localize "STR_WC_MESSAGEMISSIONFAILED", localize "STR_WC_MESSAGELEAVEZONE"];
		["wcmessageW", "client"] call WC_fnc_publicvariable;
		wcmissionsuccess = true;
		_missioncomplete = true;
	};
	if (_targetpos distance position _unit < 50) then {
		wcmessageW = [localize "STR_WC_MESSAGEMISSIONCOMPLETED", localize "STR_WC_MESSAGELEAVEZONE"];
		["wcmessageW", "client"] call WC_fnc_publicvariable;
		wcmissionsuccess = true;
		_missioncomplete = true;
		wcleveltoadd = 1;
	};
};